package com.koalac.ironman.util;

import java.lang.ref.WeakReference;

import android.os.Handler;
import android.os.Message;

public class WeakHandler<T> extends Handler{
	 WeakReference<T> mReference;
	
	public WeakHandler(T t) {
		mReference = new WeakReference<T>(t);
	}
	
	@Override
	public void handleMessage(Message msg) {
		super.handleMessage(msg);
		T t = mReference.get();
		if (t != null) {
			processMessage(t,msg);
		}
	}
	/**
	 * 实现类需覆写的方法
	 */
	protected void processMessage(T t,Message msg){}
	

}
